<?php if (!isset($_SESSION)) session_start(); ?>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="../../docs-assets/ico/favicon.png">

<title>Koreanet</title>

<!-- Nanum Webfont -->
<style>
* {
	font-family: 'NanumGothic' !important;
}
</style>
<script src="http://www.google.com/jsapi"></script>
<script>
 google.load( "webfont", "1" );
 google.setOnLoadCallback(function() {
  WebFont.load({ custom: {
   families: [ "NanumGothic" ],
   urls: [ "http://fontface.kr/NanumGothic/css" ]
  }});
 });
</script>

<!-- Bootstrap core CSS -->
<link href="./dist/css/bootstrap.css" rel="stylesheet">

<!-- Custom styles for this template -->
<link href="./css/daily_report.css" rel="stylesheet">
<link rel="stylesheet"
	href="./lib/datetimepicker/bootstrap-datetimepicker.min.css" />
</head>

<body>
<?php include 'header.php';?>
<?php require_once './class/Evaluation.inc';?>
<?php require_once './class/Evaluation_check.inc';?>
<?php

if ($getType == 1) {
	if ($login == null || $login->getGrade () > 2) {
		echo "<script type='text/javascript'>";
		echo "location.replace('./main.php');";
		echo "</script>";
		exit ();
	}
}

$search_date = $_GET['date1'];

if($search_date == ""){
	$search_date = substr(date('Y/m/d'),0,4);	
}


$eval_check = new Evaluation_check();
$eval_check -> time_check('2',$login->getSession(),date('Y/m/d'));

$rate_search = new Evaluation_check();
$rate_search -> rate_search('2',$eval_check->timecheck,'','');

$rate_val1 = $rate_search->ratevalue1;
$rate_val2 = $rate_search->ratevalue2;





?>
	<div class="container container_bottom">
		<div class="row row_margin">
			<div class="col-md-12">
				<h2>인사평가 조회</h2>
			</div>
		</div>
		<div class="row row_margin">
			<div class="col-md-4">
				<div id="search_date">
					<div class="input-group-wrapper first_wrapper">
						<div class='input-group date' id='picker1'>
							<span class='input-group-addon'>날짜(년도)</span> <select
									class="form-control" id="date1" name="date1"
									onchange="javascript:changeDelemiter(this)">
									
									<?php 
										$eval_date = new Evaluation_check();
										$eval_date -> date_search('3',$login->getSession(),$search_date."/12/31");
										
									?>
								</select>
							</span>
						</div>
					</div>
				</div>
			</div>
			<div class="col-md-8 button_align">
				<div class="row row_margin row_top" style="float:right;">
					<div class='btn-group'>
						<button class='btn btn-lg btn-info' type='button' onclick='javascript:excelDown()'>엑셀 받기</button>
					</div>
					<div class='btn-group'>
						<button class="btn btn-lg btn-success" type="button"
								onclick="location.href='./evaluation_setting.php?pageType=1'">평가설정</button>
					</div>
				</div>
			</div>
		</div>
		<!-- 
		<div class="row row_margin" style="margin: 50px 0 20px 0;">
			
			<div class="col-md-4">
				<div class="input-group-wrapper_search">
					<div class="input-group">
						<span class='input-group-addon'>수익률</span>
						<input id='r1val' type='text' class="form-control" value="<?php echo $rate_val1;?>" />
						<?php if($eval_check->timecheck != ''){?>
						<span class='input-group-addon input-group-addon-end'>
							<button class='btn btn-default btn-calendar' onclick="rate_save('401','<?php echo $eval_check->timecheck;?>');">저장</button>
						</span>
						<?php } ?>
					</div>
				</div>
			</div>
			<div class="col-md-4">
				<div class="input-group-wrapper_search">
					<div class="input-group">
						<span class='input-group-addon'>성장률</span>
						<input id='r2val' type='text' class="form-control" value="<?php echo $rate_val2;?>" />
						<?php if($eval_check->timecheck != ''){?>
						<span class='input-group-addon input-group-addon-end'>
							<button class='btn btn-default btn-calendar' onclick="rate_save('402','<?php echo $eval_check->timecheck;?>');">저장</button>
						</span>
						<?php } ?>
					</div>
				</div>
			</div>
			 
		</div>
		-->
		<form class="form-signin" role="form"
			<?php
			if ($getType == null || empty ( $getType )) {
				echo "action='./ajax/modify_daily_report.php'";
			} else if ($getType == 1) {
				echo "action='./ajax/create_daily_report.php'";
			}
			?>
			method="post">
			
			<div class="row row_margin">
				<div class="col-md-12">
					<div class="row row_margin row_top">
						<table class="table table-bordered" id="attendance_table">
							<?php
								$eval = new Evaluation();
								$eval->search4table_result("11",$search_date."/12/31",$login->getSession());
							?>
						</table>
					</div>
				</div>
				<!-- 추가 부분 -->
			</div>
			
		</form>
	</div>
	<!-- /container -->

	<!-- Bootstrap core JavaScript
    ================================================== -->
	<!-- Placed at the end of the document so the pages load faster -->
	<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
	<script src="./dist/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="./lib/moment/moment.js"></script>
	<script type="text/javascript" src="./lib/moment/transition.js"></script>
	<script type="text/javascript" src="./lib/moment/collapse.js"></script>
	<script type="text/javascript"
		src="./lib/datetimepicker/bootstrap-datetimepicker.min.js"></script>

	<script type="text/javascript">
	$(window).load(function () {
		$('#picker1').datetimepicker({
			pickTime: false
		});
	});

	$(document).ready(function () {
		$('#date1').val(<?php echo $search_date; ?>);
	});
	function eval_submit(arg){
		var param = '';

		param = '?table=1&mem_id='+$('#mem_id'+arg).val()+'&work_time='+$('#work_time'+arg).val()+'&total_score='+$('#total_score'+arg).val()+'&grade='+$('#grade'+arg).val();
		location.href='./ajax/create_evaluation_grade.php'+param;
	}
	function excelDown()
	{
		location.href='./XLS.php?type=11&sDate='+document.getElementById("date1").value
		+'/12/31&eDate=';
	}
	function rate_save(arg,time){
		var param = "";
		if(arg == "401"){
			param = "?table=1&work_time="+time+"&ratecode="+arg+"&ratevalue="+$('#r1val').val();
		}else{
			param = "?table=1&work_time="+time+"&ratecode="+arg+"&ratevalue="+$('#r2val').val();
		}

		var q = confirm(time.substring(0,4)+"년 "+time.substring(5,7)+"월 성장률(또는 수익률)을 저장하시겠습니까?")
		if (q == true)
		{
			location.href='./ajax/create_evaluation_rate.php'+param;
		}

		//location.href='./ajax/create_evaluation_rate.php'+param;
		//alert(param);
	}
	function changeDelemiter(obj){
		location.href="./evaluation_report.php?date1="+obj.value;
	}
	</script>
</body>
</html>